﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/MainFrame.Master"
	Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	管理员后台
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Header" runat="server">
	<link href="<%=Url.Content("~/Content/css/admin.css") %>" rel="Stylesheet" type="text/css" />
	<link href="<%=Url.Content("~/Content/css/ui.jqgrid.css") %>" rel="Stylesheet" type="text/css" />
	<script type="text/javascript" src="<%=Url.Content("~/Scripts/jquery.layout.js") %>"></script>
	<script type="text/javascript" src="<%=Url.Content("~/Scripts/i18n/grid.locale-cn.js") %>"></script>
	<script type="text/javascript" src="<%=Url.Content("~/Scripts/jquery.jqGrid.min.js") %>"></script>
	<style type="text/css">
html, body {
	margin: 0;			/* Remove body margin/padding */
	padding: 0;
	overflow: hidden;	/* Remove scroll bars on browser window */	
	font-size: 75%;
}
/*Splitter style */


#LeftPanel {
	/* optional, initial splitbar position */
	overflow: auto;
}
/*
 * Right-side element of the splitter.
*/

#RightPanel {
	padding: 2px;
	overflow: auto;
}
.ui-tabs-nav li {position: relative;}
.ui-tabs-selected a span {padding-right: 10px;}
.ui-tabs-close {display: none;position: absolute;top: 3px;right: 0px;z-index: 800;width: 16px;height: 14px;font-size: 10px; font-style: normal;cursor: pointer;}
.ui-tabs-selected .ui-tabs-close {display: block;}
.ui-layout-west .ui-jqgrid tr.jqgrow td { border-bottom: 0px none;}
.ui-datepicker {z-index:1200;}
.link:hover{cursor:pointer;margin:3px}
</style>
	<script type="text/javascript">
		function LoadFunction(url) {
			$.ajax({
				url: url,
				beforeSend: function () {
					$.blockUI();
				},
				success: function (data) {
					$("#right").html(data);
					InitDialogLink($("a.dialog"), $("#dlgPanel"));
					$.unblockUI();
				}
			});
}
var tabID = null;
var tabUrl = null;
$(function () {
	$('body').layout({
		resizerClass: 'ui-state-default',
		west__onresize: function (pane, $Pane) {
			jQuery("#west-grid").jqGrid('setGridWidth', $Pane.innerWidth() - 2);
		}
	});

	var maintab = $('#tabs', '#RightPanel').tabs({
		add: function (e, ui) {
			// append close thingy
			$(ui.tab).parents('li:first')
				.append('<span class="ui-tabs-close ui-icon ui-icon-close" title="Close Tab"></span>')
				.find('span.ui-tabs-close')
				.click(function () {
					maintab.tabs('remove', $('li', maintab).index($(this).parents('li:first')[0]));
				});
			// select just added tab
			maintab.tabs('select', '#' + ui.panel.id);
		},
		select: function (e, ui) {
			tabID = ui.panel.id;
			tabUrl = $("#" + ui.panel.id.replace("t", "")).find("a").attr("href");
		}
	});
	var westGrid = $("#west-grid");
	$.ajax({
		url: '/Json/GetAdmin',
		type: "POST",
		success: function (data) {
			$.each(data, function (index, data) {
				var aLink = $('<div id="link_' + data.ActionID + '"><img style="width:12px;height:12px" src="' + data.Icon + '"/><span class="link">' +
				data.LinkName +
				'</span><a style="display:none" href="' + data.Url + '"></a></div>');

				westGrid.append($("<tr></tr>").append($("<td></td>").append(aLink)));
			});
			tableToGrid(westGrid, { onSelectRow: function (rowid) {
				var div = $("#west-grid tbody tr:eq("+rowid+") td div");
				var st = "#t" + div.attr("id");
				var url = div.find("a").attr("href");
				var name = div.find("span").text();
				if ($(st).html() != null) {
					maintab.tabs('select', st);
					$(st, "#tabs").html("Just Loading!!!");
					$(st, "#tabs").load(url, function () {
						InitDialogLink($("a.dialog"), $("#dialogPanel"));
					});
				} else {
					maintab.tabs('add', st, name);
					$(st, "#tabs").html("Just Loading!!!");
					$(st, "#tabs").load(url, function () {
						InitDialogLink($(st+" a.dialog"), $("#dialogPanel"));
					});
				}
			}
			});
		}
	});


	//	$("#west-grid").jqGrid({
	//		treeGridModel: 'adjacency',
	//		url: "/Administrator/GetItems",
	//		datatype: "json",
	//		height: "auto",
	//		pager: false,
	//		loadui: "ensable",
	//		colNames: ["id", "Items", "url"],
	//		colModel: [
	//			{ name: "id", width: 20, hidden: false, key: true },
	//			{ name: "menu", width: 150, resizable: false, sortable: false },
	//			{ name: "url", width: 1, hidden: true }
	//		],
	//		treeGrid: true,
	//		caption: "jqGrid Demos",
	//		ExpandColumn: "menu",
	//		autowidth: true,
	//		//width: 180,
	//		rowNum: 200,
	//		ExpandColClick: true,
	//		treeIcons: { leaf: 'ui-icon-document-b' },
	//		onSelectRow: function (rowid) {
	//			var treedata = $("#west-grid").jqGrid('getRowData', rowid);
	//			if (treedata.isLeaf == "true") {
	//				//treedata.url
	//				var st = "#t" + treedata.id;
	//				if ($(st).html() != null) {
	//					maintab.tabs('select', st);
	//					$(st, "#tabs").html("Just Loading!!!");
	//					$(st, "#tabs").load(treedata.url, function () {
	//						InitDialogLink($("a.dialog"), $("#dialogPanel"));
	//					});
	//				} else {
	//					maintab.tabs('add', st, treedata.menu);
	//					$(st, "#tabs").html("Just Loading!!!");
	//					$(st, "#tabs").load(treedata.url, function () {
	//						InitDialogLink($("a.dialog"), $("#dialogPanel"));
	//					});
	//				}
	//			}
	//		}
	//	});

});
	</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

	 <div id="LeftPanel" class="ui-layout-west ui-widget ui-widget-content">
		<table id="west-grid">
			<tr>
				<th>导航菜单</th>
			</tr>
		</table>
	</div> <!-- #LeftPane -->

	<div id="RightPanel" class="ui-layout-center ui-helper-reset ui-widget-content" ><!-- Tabs pane -->
		<div id="tabs" class="jqgtabs">
			<ul>
				<li><a href="#tabs-1">首页</a></li>
			</ul>
			<div id="tabs-1" style="font-size:12px;"> 欢迎使用管理员后台<br/>
			</div>
		</div>
	</div> <!-- #RightPane -->
</asp:Content>
